import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PlantMethodVO, PlantMethodForm, PlantMethodQuery } from '@/api/agriculture/plantMethod/types';

/**
 * 查询种植方法列表
 * @param query
 * @returns {*}
 */

export const listPlantMethod = (query?: PlantMethodQuery): AxiosPromise<PlantMethodVO[]> => {
  return request({
    url: '/agriculture/plantMethod/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询种植方法详细
 * @param methodId
 */
export const getPlantMethod = (methodId: string | number): AxiosPromise<PlantMethodVO> => {
  return request({
    url: '/agriculture/plantMethod/' + methodId,
    method: 'get'
  });
};

/**
 * 新增种植方法
 * @param data
 */
export const addPlantMethod = (data: PlantMethodForm) => {
  return request({
    url: '/agriculture/plantMethod',
    method: 'post',
    data: data
  });
};

/**
 * 修改种植方法
 * @param data
 */
export const updatePlantMethod = (data: PlantMethodForm) => {
  return request({
    url: '/agriculture/plantMethod',
    method: 'put',
    data: data
  });
};

/**
 * 删除种植方法
 * @param methodId
 */
export const delPlantMethod = (methodId: string | number | Array<string | number>) => {
  return request({
    url: '/agriculture/plantMethod/' + methodId,
    method: 'delete'
  });
};
